*******************************************************
** 					REPLICATION MATERIAL 
** 
** "Do Authoritarian Elections Help the Poor? Evidence from Russian Cities"
**					(APPENDIX ANALYSES)
**
**					   	   by 				 			 	  
**			Quintin H. Beazer & Ora John Reuter
**
**						     in							 	  
** 				The Journal of Politics		 	  
**													 	  
*******************************************************

* File created and checked May 2020 using Stata 14. To ask questions 
* or report a suspected error, please contact the authors. We are happy 
* to correspond with others about the project. Send emails to: 
* Quintin Beazer (qbeazer@fsu.edu) or John Reuter (reutero@uwm.edu) 

* This .do file contains code for reproducing the analyses in the appendix.
* Specifically, this code replicated results for Tables A1-A13.
  
* Replication code for the main analyses appears separately in the 
* accompanying .do file. Code for the plots and sensitivity analysis are
* in the accompanying .R script.



* setting working directory
cd "XXXXX"

* load dataset
use "zhilJOP.dta", clear

* setting control vars
global cvars pressfreedom workpop AvgSalary1 regdem birthrate regprom pop

set more off



** Table A1: Summary Statistics
*******************************
sum badzhil badzhilpc appointed URduma pressfreedom workpop AvgSalary1 ///
regdem birthrate regprom pop if year>=2002 & year<2013
*sum civsoc91 republic pctRussian diff_unemp unemployrate 
 

** Table A2: Dropping outliers and Controlling for Electoral Margin
*****************************************************************

* load dataset
use "zhilJOP.dta", clear

* gen electoral margin for last elected mayor
sort city_id year
by city_id: carryforward margin, gen(margin2)

* Model 1
xtreg badzhil appointed $cvars margin2 i.year, fe cluster(city_id)
estimates store marg

* Model 2 
xtreg badzhilpc appointed $cvars margin2 i.year, fe cluster(city_id)
estimates store margpc

* Model 3
xtreg badzhil appointed $cvars i.year if kavkaz==0, fe cluster(city_id)
estimates store nokz

* Model 4
xtreg badzhilpc appointed $cvars i.year if kavkaz==0, fe cluster(city_id)
estimates store nokzpc

* Table A2
estout marg nokz margpc  nokzpc, ///
	cells(b( fmt(%9.3f)) se(par)  p(fmt(%9.3f)) ) stats(N r2 bic) style(tex)

	
	
** Table A3: Resettling Familes Waitlisted for New Housing
********************************************************

* load dataset
use "zhilJOP.dta", clear

* Model 1: Percent of families on waiting list moved into new housing
xtreg fam appointed $cvars i.year, fe cluster(city_id)
estimates store famreset

* Model 2: Number of families moved into new housing, per capita
xtreg resetpc appointed $cvars i.year, fe cluster(city_id)
estimates store setpc

* Table A3
estout famreset setpc, ///
	cells(b( fmt(%9.3f)) se(par)  p(fmt(%9.3f)) ) stats(N r2 bic) style(tex)


	
	
** Table A4: Survey Panel on Household Utilities Costs:
** Change to Appointed Maryos Followed by Increased Utility Costs
*****************************************************************

do RLMSmerge.do

* keep only respondents who are really in cities (not villages, etc)
keep if urban==1 | urban==2

* setting household as unit of obs
tsset id_h year

* new household vars
gen own = 0 if c1!=.
replace own =1 if c1==1

gen rent = 0 if c1!=.
replace rent =1 if c1==2

recode b1_4 (1=0) (2=1), gen(female)
gen birthyr = b1_5

*setting household control vars
global fvars nfm female birthyr own rent


* gen DV for household costs
gen housecosts = e11 
replace housecosts = . if housecosts>=99999997

* Model 1
xtreg housecosts appointed $cvars $fvars i.year, fe cluster(id_h)
estimates store costs

* gen DV for payment arrears for housing/utilities costs
gen unpaid3m = e12_2 
replace unpaid3m = . if unpaid3m>=99999997

* Model 2
xtreg unpaid3m appointed $cvars $fvars i.year, fe cluster(id_h)
estimates store unpaid

* Table A4
estout costs unpaid,  ///
	cells(b( fmt(%9.3f)) se(par)  p(fmt(%9.3f)) ) stats(N r2 bic) style(tex)  


	
	
** Table A5: Full results from truncated Table 2
***********************************************
* see .do file for main text results


** Table A6: Full results from truncated Table 3
***********************************************
* see .do file for main text results


** Table A7: Examining Interaction between Vote Delivery 
** and Bad Housing for Appointed Mayors
***********************************************

* load dataset
use "zhilJOP.dta", clear

gen lURdumaXlbadzhil = l.URduma*l.badzhil
gen lURhighXlbadzhil = l.URhigh*l.badzhil
gen lURlowXlbadzhil = l.URlow*l.badzhil

drop if mayorid==.
tsset mayorid year

* Model 1
xtreg turnover lURdumaXlbadzhil l.URduma l.badzhil l.zhiltot $cvars  i.year if appointed==1, fe cluster(city_id)
estimates store appURfeX

*Model 2
xtreg turnover  lURlowXlbadzhil l.URlow lURhighXlbadzhil l.URhigh l.badzhil l.zhiltot $cvars  i.year if appointed==1, fe cluster(city_id)
estimates store appURfehiloX

* Table A7 
estout appURfeX appURfehiloX, ///
	cells(b( fmt(%9.3f)) se(par)  p(fmt(%9.3f)) ) stats(N r2 bic) style(tex)  

	
	
** Table A8: Local Increases in Bad Housing Do Not Harm UR in National Elections
********************************************************************************

* load dataset
use "zhilJOP.dta", clear

drop if year>2012
gen badzhilXapp = badzhil*appointed 
gen badzhilpcXapp = badzhilpc*appointed

* Model 1
xtreg URduma l.badzhil l.zhiltot $cvars i.year if dumayear==1, fe cluster(city_id)
estimates store UR1

* Model 2
xtreg URduma l.badzhil l.badzhilXapp l.appointed l.zhiltot $cvars i.year if dumayear==1, fe cluster(city_id)
estimates store UR1x

* Model 3
xtreg URduma l.badzhilpc $cvars i.year if dumayear==1, fe cluster(city_id)
estimates store UR2

* Model 4
xtreg URduma l.badzhilpc l.badzhilpcXapp l.appointed $cvars i.year if dumayear==1, fe cluster(city_id)
estimates store UR2x

* Table A8:
estout UR1 UR1x UR2 UR2x, ///
	cells(b( fmt(%9.3f)) se(par)  p(fmt(%9.3f)) ) stats(N r2 bic) style(tex)

	



** Table A9: Municipal Budgets Do Not Increase from Having More Bad Housing
***************************************************************************

* load dataset
use "zhilJOP.dta", clear

*making new vars
gen lgrants = log(grants+1)
gen grantspc = grants/1000/pop /*1000s of rubles per cap */


* Model 1
xtreg f.lgrants badzhil zhiltot $cvars i.year if year<2013, fe cluster(city_id)
estimates store lg

* Model 2
xtreg f.grantspc badzhil zhiltot $cvars i.year if year<2013, fe cluster(city_id)
estimates store lgpc

* Model 3
xtreg f.lgrants badzhilpc $cvars i.year if year<2013, fe cluster(city_id)
estimates store lg2

* Model 4
xtreg f.grantspc badzhilpc $cvars i.year if year<2013, fe cluster(city_id)
estimates store lgpc2

* Table A9:
estout lg lgpc lg2 lgpc2, ///
	cells(b( fmt(%9.3f)) se(par)  p(fmt(%9.3f)) ) stats(N r2 bic) style(tex)

	

** Table A10: Full results from truncated Table 4
***********************************************
* see .do file for main text results

	
	
** Table A11: Controlling for Municipal Revenues & Social Unrest
*****************************************************************

* load dataset
use "zhilJOP.dta", clear

* gen logged revenues
gen lrevtot = log(revtot + 1)


* Model 1
xtreg badzhil appointed l.URduma lURdumaXapp zhiltot l.lrevtot $cvars i.year, fe cluster(city_id)
estimates store budgetXfe

* Model 2
xtreg badzhil appointed l.URduma lURdumaXapp zhiltot nprotest $cvars i.year, fe cluster(city_id)
estimates store protestXfe

* Model 3
xtreg badzhil appointed l.URhigh lURhighXapp zhiltot l.lrevtot $cvars i.year, fe cluster(city_id)
estimates store budgetXdv

* Model 4
xtreg badzhil appointed l.URhigh lURhighXapp zhiltot nprotest $cvars i.year, fe cluster(city_id)
estimates store protestXdv

* Table A11: 
estout budgetXfe budgetXdv protestXfe protestXdv, ///
	cells(b( fmt(%9.3f)) se(par)  p(fmt(%9.3f)) ) stats(N r2 bic) style(tex)
	
	
	
**  Table A12: Comparing Pre-Reform Differences in Russian Municipalities
******************************************************************  

* load dataset
use "zhilJOP.dta", clear

ttest zhilrat if appointed==0, by(appcity)
ttest badzhilpc if appointed==0, by(appcity)
ttest URduma if appointed==0 & year==2003, by(appcity)
ttest URduma if appointed==0 & year==2007, by(appcity)
ttest URduma if appointed==0 & year==2011, by(appcity)
ttest unemployrate if appointed==0, by(appcity)
ttest diff_unemp if appointed==0, by(appcity)


** Table A13: Full results from truncated Table 5
***********************************************
* see .do file for main text results

